/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.cardarus.operatingsystem.domain;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;

/**
 * This class represents a reminder. Customer registers REMIND plan and
 * then manager his own reminders.
 * 
 * @author Javier Snaider
 */
@Entity
public class Reminder implements Serializable {

    /**
     * The id of the reminder.
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;

    /**
     * The Customer associated with this reminder.
     */
    @ManyToOne
    private Customer customer;

    /**
     * The date of creating this reminder.
     */
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date creationDate;

    /**
     * The date of need to remind.
     */
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date reminderDate;

    /**
     * The description of this reminder concept.
     */
    private String description;

    /**
     * The type of this reminder, like birthday or anniversary.
     */
    private ReminderType type;

    /**
     * @return the multiple reminder types
     */
    public ReminderType[] getTypes(){
        return ReminderType.values();
    }

    /**
     * @return the reminder id
     */
    public int getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * @return the customer of this reminder
     */
    public Customer getCustomer() {
        return customer;
    }

    /**
     * @param customer the customer to set
     */
    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    /**
     * @return the creationDate
     */
    public Date getCreationDate() {
        return creationDate;
    }

    /**
     * @param creationDate the creationDate to set
     */
    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    /**
     * @return the reminderDate
     */
    public Date getReminderDate() {
        return reminderDate;
    }

    /**
     * @param reminderDate the reminderDate to set
     */
    public void setReminderDate(Date reminderDate) {
        this.reminderDate = reminderDate;
    }

    /**
     * @return the description of this reminder
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return reminder type
     */
    public ReminderType getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(ReminderType type) {
        this.type = type;
    }


    @Override
    public int hashCode() {
        int hash = 0;
        hash += (int)id ;
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Reminder)) {
            return false;
        }
        Reminder other = (Reminder) object;
        if (this.id != other.id) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Reminder{" + "id=" + id + "customerUserName=" + customer.getUserName() + "creationDate=" + creationDate + "reminderDate=" + reminderDate + "description=" + description + "type=" + type + '}';
    }

}
